package com.smedi.ismedi.progress.core.domain.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.smedi.ismedi.progress.api.dto.request.VersionManageCreateRequest;
import com.smedi.ismedi.progress.core.application.command.ProgressViewCommand;
import com.smedi.ismedi.progress.core.domain.repository.ProjectVersionRepository;
import com.smedi.ismedi.progress.core.domain.service.ProjectVersionDomainServer;
import com.smedi.ismedi.progress.core.port.adapter.persistence.model.VersionManageEntity;
import com.smedi.ismedi.web.starter.common.ResponseData;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author hexu@goldbeacon.cn
 * @version 1.0
 * @remark ...
 * @date 2022/10/11 15:15
 */
@Service
@AllArgsConstructor
public class ProjectVersionDomainServerImpl implements ProjectVersionDomainServer {
    private final ProjectVersionRepository projectVersionRepository;
    /**
     * 导入mpp project文件，创建项目版本信息
     *
     * @param projectFile                project文件
     * @param versionManageCreateRequest 请求参数
     * @return 版本表主键
     */
    @Override
    public void versionImport(MultipartFile projectFile, VersionManageCreateRequest versionManageCreateRequest) {
        projectVersionRepository.versionImport(projectFile, versionManageCreateRequest);
    }

    @Override
    public ResponseEntity<byte[]> downloadProjectTemplateFile() {
        return projectVersionRepository.downloadProjectTemplateFile();
    }

    @Override
    public String cancelVersion(ProgressViewCommand progressViewCommand) {
        return projectVersionRepository.cancelVersion(progressViewCommand);
    }
}
